package com.bzyd.mp.datascope.strategy;

import com.bzyd.mp.datascope.DataScopeParam;
import com.bzyd.mp.utils.UserContextUtil;
import net.sf.jsqlparser.expression.Expression;

/**
 * 可以查看自己所在部门及子部门的
 */
public class OwnChildDeptDataScopeStrategy implements DataScopeStrategy {

    //注意：mybatis plus拦截器循环依赖问题
    //不能注意UserService、UserMapper等有SqlSessionFactory依赖的对象

    @Override
    public String mode() {
        return "own_child_dept";
    }

    @Override
    public Expression buildWhere(Expression where, String mappedStatementId, DataScopeParam dataScopeParam) {
        return grantOwnChildDept(where, dataScopeParam, UserContextUtil.getDeptCode());
    }
}
